<table class="search_results">
	<thead>
		<tr>
			<td>
				<h1>Sökresultat</h1>
			</td><td>	
				<h2><?php echo $hits; ?> träffar</h2>
			</td>	
		</tr>
	</thead>
	<tbody>
		<tr><td colspan="2"><img src="/img/search_res_line.png" class="table_line" /></td></tr>
		<tr>	
			<td colspan="2">
				<?php if(count($results) == 0) : ?>
					<em>Fick inga träffar på dina sökord!</em>
				<?php else: ?>
					<table class="c_list">
						<?php $i=0;foreach($results as $r) : ?>
						<tr id="prev_1" more="viewmore_<?php echo $i;?>" class="c_prev">
							<td><?php echo ucwords($r->name);?></td>
							<td><?php echo ucwords($r->branchname);?></td>
							<td>Tfn: <?php echo $r->phone;?></td>
							<td><span class="c_viewmore_btn"></div></td>
						</tr>
						<tr class="c_viewmore" id="viewmore_<?php echo $i;?>">
							<td colspan="2">
								<p><a href="<?php echo $r->homepage;?>" target="_blank">Webbsida</a></p>
								<p><?php echo $r->address;?></p>
							</td>
							<td colspan="2">
								<a class="c_moreinfo_btn" href="/foretag/<?php echo $r->slug;?>">Mer info</a>
							</td>
						</tr>
						<?php $i++;endforeach; ?>
					</table>
				<?php endif; ?>
			</td>
		</tr>
	</tbody>
</table>

<!--
<table class="search_related">
	<thead>
		<tr>
			<td>
				<h1>Relaterat</h1>
			</td><td>	
				<h2>3 företag</h2>
			</td>	
		</tr>
	</thead>
	<tbody>
		<tr><td colspan="2"><img src="/img/search_rel_line.png" class="table_line" /></td></tr>
		<tr>	
			<td colspan="2">
				<table class="r_list">
					<tr>
						<td>Twify Industries HB</td>
						<td>Webbyrå</td>
						<td><span class="c_viewmore_btn"></div></td>
					</tr>
					<tr>
						<td>Twify Industries HB</td>
						<td>Webbyrå</td>
						<td><span class="c_viewmore_btn"></div></td>
					</tr>
					<tr>
						<td>Twify Industries HB</td>
						<td>Webbyrå</td>
						<td><span class="c_viewmore_btn"></div></td>
					</tr>
				</table>
			</td>
		</tr>
	</tbody>
</table>

-->
<script language="javascript" type="text/javascript">
	$(document).ready(function(){
		$("tr.c_prev").click(function(e){

			var target = $("#"+$(this).attr("more"));
			var open = ! $(this).hasClass("open"); // should we open a row ?
			
			$("tr.open").removeClass("open");
			$("tr.c_viewmore").hide();

			if(open) {
				$(this).addClass("open");
				target.show();
			}
		});
	});
</script>